<?php
// 清文件缓存
$dirs = array('./data/template/');

// 清理缓存
foreach ($dirs as $dir) {
	rmdirr($dir);
	echo "<div style='border:2px solid green; background:#f1f1f1; padding:20px;margin:20px;width:800px;font-weight:bold;color:green;text-align:center;'>\"" . $dir . "\" have been cleaned clear! </div> <br /><br />";
}

// 重新新建目录
foreach ($dirs as $dir) {
	@mkdir($dir, 0777, true);
}

function rmdirr($dirname) {
	if (!file_exists($dirname)) {
		return false;
	}
	if (is_file($dirname) || is_link($dirname)) {
		return unlink($dirname);
	}
	$dir = dir($dirname);
	if ($dir) {
		while (false !== $entry = $dir->read()) {
			if ($entry == '.' || $entry == '..') {
				continue;
			}
			rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
		}
	}
	$dir->close();
	return rmdir($dirname);
}
?>